using System.Linq;
using AndyPike.Commons.Persistence;
using AndyPike.Snowflake.Entities;

namespace AndyPike.Snowflake.Core.Queries.Accounts
{
    public class AccountByUserName : IQueryCommand<Account>
    {
        private readonly string userName;

        public AccountByUserName(string userName)
        {
            this.userName = userName;
        }

        public IQueryable<Account> Execute(IRepository<Account> repository)
        {
            return repository.AsQueryable().Where(a => a.UserName == userName);
        }
    }
}